<%@ page import="java.util.*"%>

<%
	String localSession = session.getId();
	String remoteSession = request.getParameter("session_id");
	String target = request.getParameter("target");
	String logout = request.getParameter("logout");
	String login = request.getParameter("login");
	String org_id = request.getParameter("org_id");
	String site = request.getParameter("site");
	String home = request.getContextPath() + "/home.jsp";
	String currentPage = request.getRequestURI();
	StringBuffer currentUrl = request.getRequestURL();
	String[] splitPage = currentPage.split("/");
	String loginPage = "login.jsp";
	String homePage = "home.jsp";
  String reportPage = "viewReport.jsp";
  String empnum = (String) session.getAttribute("GID");
  String role = (String) session.getAttribute("Roles");
  if(role == null)
    role = "User";
  
	if (logout != null) {
               empnum = null;
		session.invalidate();
	}
  
	if (splitPage.length == 3) {
		if ((!loginPage.equals(splitPage[2]))&&(empnum == null) && (!reportPage.equals(splitPage[2]))) {
			String destination = "login.jsp?target="+splitPage[2];
			response.sendRedirect(response.encodeRedirectURL(destination));
		}
	}
  
%>
